package cn.edu.ujn.lab.service;

import cn.edu.ujn.lab.dao.LendList;
import cn.edu.ujn.lab.dao.LendListMapper;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
@Service
@Transactional
public class LendListServiceImpl implements ILenListService{


    @Autowired
    private LendListMapper lendListDao;

    @Override
    public LendList findById(Integer id) {
        return lendListDao.selectByPrimaryKey(id);
    }

    @Override
    public LendList insert(LendList lendList) {
        int insert = lendListDao.insert(lendList);
        return lendList;
    }

    @Override
    public List<LendList> findAll() {
        return lendListDao.findAll();
    }

    @Override
    public LendList update(LendList lendList) {
        int i = lendListDao.updateByPrimaryKey(lendList);
        return lendList;
    }

    @Override
    public Integer delete(Integer id) {
        return lendListDao.deleteByPrimaryKey(id);
    }

    @Override
    public Page<LendList> selectAll(LendList lendList) {
        List<LendList> list=lendListDao.selectAll(lendList);
        Page<LendList> page = new Page<LendList>();
        page.setSize(lendList.getRows());
        page.setRows(list);
        page.setPage(lendList.getStart());
        page.setTotal(lendListDao.selectCount());
        return page;
    }
}
